#!/bin/sh

CONFDIR=config

localln()
{
    \rm -rf ~/.vim
    ln -svf ${CONFDIR}/vim/vimrc            .vimrc
    ln -svf ${CONFDIR}/vim/vim              .vim
    ln -svf ${CONFDIR}/bash/bashrc          .bashrc
    ln -svf ${CONFDIR}/bash/aliasrc         .aliasrc
    ln -svf ${CONFDIR}/bash/gitfunc         .gitfunc
    ln -svf ${CONFDIR}/git/gitconfig        .gitconfig
    ln -svf ${CONFDIR}/bash/functionsrc     .functionsrc
    ln -svf ${CONFDIR}/bash/bash_profile    .bash_profile
    ln -svf ${CONFDIR}/bash/gopath          .gopath
}
userhomelocalln()
{
    cd
    localln
    cd -
}

if [ $# -ne 1 ]; then
    echo "Usage: $0 [oschina | github | localhost]"
    exit 1
fi

case $1 in
    localhost)
        userhomelocalln
        exit 0
        ;;
    oschina)
        ORIGIN=http://git.oschina.net/yuanhack/config.git
        ;;
    github)
        ORIGIN=git://github.com/yuanhack/config.git
        ;;
    *)
        echo "Usage: $0 [oschina | github | localhost]"
        exit 1
esac

cd
\rm -rf ${CONFDIR}
git clone ${ORIGIN}
cd -

userhomelocalln

echo done.
